package visualTwo;

import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.WindowEvent;
import java.awt.event.WindowListener;

import javax.swing.AbstractAction;
import javax.swing.JFrame;
import javax.swing.JScrollPane;

public class VisualTwoFrame extends JFrame{
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	boolean isClosing;
	
	public VisualTwoFrame(){
		this.setSize(650, 600);
		this.setVisible(true);
		this.getContentPane().setBackground(Color.BLACK);
		this.setLayout(new GridLayout(1, 1));
		this.addWindowListener(new WindowListener(){

			@Override
			public void windowActivated(WindowEvent arg0) {
				// TODO Auto-generated method stub
				
			}

			@Override
			public void windowClosed(WindowEvent arg0) {
				System.out.println("1");
				isClosing=true;
			}

			@Override
			public void windowClosing(WindowEvent arg0) {
				System.out.println("2");
				isClosing=true;
				System.exit(0);
			}

			@Override
			public void windowDeactivated(WindowEvent arg0) {
				// TODO Auto-generated method stub
				
			}

			@Override
			public void windowDeiconified(WindowEvent arg0) {
				// TODO Auto-generated method stub
				
			}

			@Override
			public void windowIconified(WindowEvent arg0) {
				// TODO Auto-generated method stub
				
			}

			@Override
			public void windowOpened(WindowEvent arg0) {
				// TODO Auto-generated method stub
				
			}
			
		});
		
		WheelPanel wheel = new WheelPanel();
		
		//this.repaint();
		//this.getGraphics().setColor(Color.BLACK);
		//this.getGraphics().drawRect(0, 0, 1000, 1000);
		
		JScrollPane scrolly = new JScrollPane(wheel, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
		scrolly.setViewportView(wheel);
		scrolly.setWheelScrollingEnabled(false);
		
		scrolly.getActionMap().put("unitScrollRight", new AbstractAction(){
		    /**
			 * 
			 */
			private static final long serialVersionUID = 1L;

			@Override
		    public void actionPerformed(ActionEvent e) {
		    }});
		scrolly.getActionMap().put("unitScrollDown", new AbstractAction(){
		    /**
			 * 
			 */
			private static final long serialVersionUID = 1L;

			@Override
		    public void actionPerformed(ActionEvent e) {
		    }});
		scrolly.getActionMap().put("unitScrollUp", new AbstractAction(){
		    /**
			 * 
			 */
			private static final long serialVersionUID = 1L;

			@Override
		    public void actionPerformed(ActionEvent e) {
		    }});
		scrolly.getActionMap().put("unitScrollLeft", new AbstractAction(){
		    /**
			 * 
			 */
			private static final long serialVersionUID = 1L;

			@Override
		    public void actionPerformed(ActionEvent e) {
		    }});
		
		//scrolly.setPreferredSize(new Dimension(600, 550));
		
		add(scrolly, BorderLayout.SOUTH);
		//for(int i = 1; i<200; i++){
			wheel.calcGroup(91);
			this.validate();
			
			while(true){
				wheel.inputLogic();
				try {
					Thread.sleep(1000/60);
				} catch (InterruptedException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
			}
			
			//if(i<199)
				//wheel.clear();
		//}
		//System.out.println("Done");
	}
	
	public static void main(String[] antidisestablishmentarianisms){
		//System.setProperty("sun.awt.noerasebackground", "true");
		new VisualTwoFrame();
	}
}
